Release 10.1A: OpenEdge Development:
Programming Interfaces
Additional options for printing in Windows
In Windows, you can also get a list of printers, change the default printer for the session, and provide access to the Print dialog box.
Getting a list of printers
You can use the
GET-PRINTERSoption of theSESSIONstatement to obtain a list of the printers configured for the current system. The following example shows you how to obtain the list of currently configured printers, select a printer, and print to it:
The following list explains the important elements in the example above:
- Create two variables: one for the output of
SESSION:GET–PRINTERS; the other, for the output ofLOOKUP.- The
SESSION: GET–PRINTERSmethod returns a comma-separated list of printers that are currently configured on the system.- The
LOOKUPfunction obtains an integer that gives the position of “SpecialPrinter” in the list. If the printer is not in the list, it returns a 0.- The
IFstatement determines whether the printer “SpecialPrinter” is available and if so, prints to it.- If the printer “SpecialPrinter” is not available, the
ELSEDOstatement prints to the default printer.- The
OUTPUTCLOSEstatement stops sending output to the current destination and redirects output to the destination used prior toOUTPUTTO. See the "Stream I/O vs. screen I/O" section for more information.Changing the default printer
To change the default printer for the session, you can use the
PRINTER–NAMEoption of theSESSIONstatement as shown in the following example:
![]()
To change the default printer:
- Create a variable for the output of
SESSION:PRINTER–NAME.- The
SESSION:PRINTER–NAMEattribute returns the name of the default printer.- The
SESSION:PRINTER–NAMEattribute sets another printer,\\AB1\hplaser, as the default printer.- The
OUTPUT TO PRINTERprints the report on the printer \\AB1\hplaser.- The
SESSION:PRINTER–NAMEattribute restores the original default printer.Providing access to the print dialog box
You can use the
SYSTEM–DIALOG PRINTER–SETUPstatement to provide access to the Windows print dialog box. This allows the application user to set up the printer or even change the printer that receives the output.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |